home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0008_Text File Management.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  721 b   |  48 lines

  1. unit textfile;
  2.  
  3. INTERFACE
  4.  
  5. function  numlines1(n:string):longint;
  6. function  numlines2(var f:text):longint;
  7.  
  8. IMPLEMENTATION
  9.  
  10. function numlines1(n:string):longint;
  11. var
  12.   f:text;
  13.   c:longint;
  14. begin
  15.   numlines1:=-1;
  16.   assign(f,n);
  17.   {$i-} reset(f); {$i+}
  18.   if(ioresult<>0)then exit;
  19.   c:=0;
  20.   while not eof(f)do
  21.   begin
  22.     readln(f);
  23.     inc(c);
  24.   end;
  25.   numlines1:=c;
  26.   close(f);
  27. end;
  28.  
  29. function numlines2(var f:text):longint;
  30. var
  31.   c:longint;
  32. begin
  33.   numlines2:=-1;
  34.   {$i-} close(f); {$i+}
  35.   if(ioresult<>0)then ;
  36.   {$i-} reset(f); {$i+}
  37.   if(ioresult<>0)then exit;
  38.   c:=0;
  39.   while not eof(f)do
  40.   begin
  41.     readln(f);
  42.     inc(c);
  43.   end;
  44.   numlines2:=c;
  45.   close(f);
  46. end;
  47.  
  48. end.